package thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread rose = new Thread("rose"){
            public void run(){
                System.out.println(getName()+":let me go!");
                for(int i = 0; i < 5; i++){
                    System.out.println(getName()+":let me go");
                    try {
                        Thread.sleep(1000L);
                    } catch (InterruptedException e) {

                    }
                }
                System.out.println("啊！~");
                System.out.println("噗通！");
            }
        };

        Thread jack = new Thread("jack"){
            public void run(){
                while(true){
                    System.out.println(getName()+":you jump,i jump");
                    try {
                        Thread.sleep(1000L);
                    } catch (InterruptedException e) {

                    }
                }
            }
        };
        rose.start();

        jack.setDaemon(true);
        jack.start();

        while(true);//所有用户线程都结束，守护线程才结束，进程结束
    }
}
